package com.ipet.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ipet.modules.sys.entity.PetCategoryEntity;
import com.ipet.modules.sys.service.PetCategoryService;
import com.ipet.common.utils.PageUtils;
import com.ipet.common.utils.R;



/**
 * 宠物类别表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-03-23 16:11:25
 */
@RestController
@RequestMapping("sys/petcategory")
public class PetCategoryController {
    @Autowired
    private PetCategoryService petCategoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:petcategory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = petCategoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:petcategory:info")
    public R info(@PathVariable("id") Integer id){
			PetCategoryEntity petCategory = petCategoryService.selectById(id);

        return R.ok().put("petCategory", petCategory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:petcategory:save")
    public R save(@RequestBody PetCategoryEntity petCategory){
			petCategoryService.insert(petCategory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:petcategory:update")
    public R update(@RequestBody PetCategoryEntity petCategory){
			petCategoryService.updateById(petCategory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:petcategory:delete")
    public R delete(@RequestBody Integer[] ids){
			petCategoryService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
